Imports AUtility

Partial Public Class MyDetails
    Inherits System.Web.UI.Page

    Dim iRow As TLDS.IgracRow
    Dim iTable As TLDS.IgracDataTable = New TLDS.IgracDataTable()
    Dim selectStr As String

    Private Sub LoadData()
        txtImePrezime.Text = iRow.Ime + " " + iRow.Prezime
        txtMobitel.Text = iRow.Mobitel
        txtEmail.Text = iRow.Mail
        If (Not iRow.IsPictureNull()) Then
            txtPicture.Text = iRow.Picture
        End If
        txtPassword.Text = iRow.Password
        imgMe.ImageUrl = iRow.Picture

    End Sub

    Private Sub GetObjectRow()
        selectStr = String.Format("SELECT * FROM Igrac WHERE IgracId = {0}", Session("UserId"))
        DataAccess.FillTable(GlobalTenisLiga.ConnectionString, selectStr, iTable)
        iRow = CType(iTable.Rows(0), TLDS.IgracRow)
    End Sub

    Private Sub SessionBullShit()
        'Session bullshit
        If (Application("Count") IsNot Nothing) Then
            'Response.Write(Application("Count").ToString() + "<br>")
            Application("Count") = Convert.ToInt16(Application("Count")) + 1
            If (Convert.ToInt16(Application("Count")) = 2) Then
                Application("Count") = Nothing
            Else
                Session("UserId") = Application("UserId")
            End If
        End If
        'Response.Write(Session.SessionID + "<br>")
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'SessionBullShit()

        If (Session("UserId") Is Nothing) Then
            Response.Redirect("Login.aspx")
        End If
        GetObjectRow()
        If (Not IsPostBack) Then
            LoadData()
        End If
        'Response.Write(Session.SessionID)
    End Sub

    Protected Sub btnSpremi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSpremi.Click
        iRow.Mobitel = txtMobitel.Text
        iRow.Mail = txtEmail.Text
        If (txtPicture.Text.Trim() = String.Empty) Then
            iRow.Picture = "http://www.mojweb.org/img/1.jpg"
        Else
            iRow.Picture = txtPicture.Text
        End If
        iRow.Password = txtPassword.Text

        Dim iTA As TLDSTableAdapters.IgracTableAdapter = New TLDSTableAdapters.IgracTableAdapter()
        iTA.Update(iTable)
        LoadData()
        lblMessage.Visible = True
        lblMessage.Text = "Spremljeno!"
    End Sub
End Class